<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Product extends Model
{
    protected $table = 'product';

    public function getType()
    {
        return $this->belongsTo('App\ProductType', 'type', 'id');
    }

    public function getRecommend($index)
    {
        $recommend = [
            '推荐',
            '不推荐'
        ];
        return $recommend[$index];
    }

    public function getPicturesAttribute($value)
    {
        return explode(',', $value);
    }
}
